package com.kantboot.api.alicloud.setting;

import com.aliyun.auth.credentials.Credential;
import com.aliyun.auth.credentials.provider.StaticCredentialProvider;
import com.kantboot.system.setting.service.ISysSettingService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

/**
 * 关于阿里云的配置
 */
@Component
public class ApiAliCloudSetting {

    @Resource
    private ISysSettingService settingService;

    /**
     * 获取阿里云的accessKeyId和accessKeySecret
     */
    public StaticCredentialProvider getStaticCredentialProvider(){
        String accessKeyId = settingService.getValue("aliCloud", "accessKeyId");
        String accessKeySecret = settingService.getValue("aliCloud", "accessKeySecret");

        return StaticCredentialProvider.create(Credential.builder()
                .accessKeyId(accessKeyId)
                .accessKeySecret(accessKeySecret)
                .build());
    }

}
